﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Collections;

namespace brockredge.handler
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        [WebMethod]
        public static ArrayList GetGenders()
        {
            return new ArrayList()
            {
                new { Value = 1, Display = "Male" },
                new { Value = 2, Display = "Female" }
            };
        }

        //[WebMethod]
        //public static ArrayList GetNames(int genderID)
        //{
        //    if (genderID.Equals(1))
        //    {
        //        return new ArrayList()
        //        {
        //            new { Value = 1, Display = "Joe" },
        //            new { Value = 1, Display = "Tom" },
        //            new { Value = 1, Display = "Sylvain" }
        //        };
        //    }
        //    else if (genderID.Equals(2))
        //    {
        //        return new ArrayList()
        //        {
        //            new { Value = 1, Display = "Emily" },
        //            new { Value = 1, Display = "Lauri" },
        //        };
        //    }
        //    else
        //    {
        //        throw new ApplicationException("Invalid Gender ID");
        //    }
        //}

        [WebMethod]
        public static ArrayList GetNames(int genderID)
        {
            if (genderID.Equals(1))
            {
                 ArrayList  cityList = new ArrayList();
               
                testDataContext tdc = new testDataContext();
                var cityQ = from city in tdc.City_States
                            select city.City;
               
                     foreach (var city in cityQ)
                    {
                        
                        cityList.Add(new{value=1,Display=city});
                    }


                     return cityList;
               
            }
            else if (genderID.Equals(2))
            {
                List<string> cityList = new List<string>();
                testDataContext tdc = new testDataContext();
                var cityQ = from city in tdc.City_States
                            select city.City;
                return new ArrayList()
                {
                    new { Value = 1, Display = "Joe" },
                    new { Value = 1, Display = "Tom" },
                    new { Value = 1, Display = "Sylvain" }
                };
                
            }
            else
            {
                throw new ApplicationException("Invalid Gender ID");
            }
        }
    }
}